package marcus.spring.form;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import marcus.age.AgeCalculator;
import marcus.jpa.dao.ContactsDao;
import marcus.jpa.entities.Contact;
import marcus.jpa.entities.User;

public class AgeModel {
	private String username;
	private Date date;
	private Map<Contact,String> contactAges;

	public String getUsername() {
		return username;
	}

	public Date getDate() {
		return date;
	}

	public Map<Contact, String> getContactAges() {
		return contactAges;
	}
	public void setUsername(String user) {
		this.username = user;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setContactAges(HashMap<Contact, String> contactAges) {
		this.contactAges = contactAges;
	}
	
	public void setContactAges(){
		User user = ContactsDao.getUser(username);
		List<Contact> contacts = ContactsDao.getContacts(user);
		contactAges = new AgeCalculator().getAges(contacts, date);
	}
}
